package com.freedom.admin.domain.service.impl;

import cn.hutool.core.lang.Assert;
import com.freedom.admin.domain.repository.SysDeptRepository;
import com.freedom.admin.domain.service.DeptService;
import com.freedom.admin.infrastructure.persistence.pojo.bo.DeptBO;
import com.freedom.common.framework.exception.ServiceException;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
public class DeptServiceImpl implements DeptService {

    private SysDeptRepository deptRepository;

    @Override
    public void modifyDept(DeptBO deptBO) {
        Boolean result = deptRepository.modifyDept(deptBO);
        Assert.isTrue(result, () -> new ServiceException("修改部门数据失败"));
    }

    @Override
    public void addDept(DeptBO deptBO) {
        Boolean result = deptRepository.addDept(deptBO);
        Assert.isTrue(result, () -> new ServiceException("新增部门数据失败"));
    }

    @Override
    public void removeDept(List<Integer> ids) {
        deptRepository.removeDept(ids);
    }
}
